function get2ClassType(){

   var sectionTypeName =  $("#sectionType").val();

    $.ajax({
        url:ip_port + "bbs/get2classtype",
        type:"post",
        data:"sectionType=" + sectionTypeName,
        success:function (msg) {

            var select  = $("#sid");
            var str="";
           for (var i = 0 ; i <  msg.length; i++){

               str+= "<option value='"+msg[i].id+"'>" + msg[i].sname + "</option>";
           }
           select.html(str);
        },
        error:function (xhr) {

        }
    });

}
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
$(document).ready(function(e) {


    var ue = UE.getEditor('editor',{
        initialFrameHeight:500,
        toolbars: [
            ['fullscreen', 'undo', 'redo'],
            ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc','simpleupload']
        ],
        autoHeightEnabled: false,
        autoFloatEnabled: false,
        elementPathEnabled:false,
        imagePathFormat: "/resources/js/ueditor/jsp/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}"

    });



    ue.ready(function() {//编辑器初始化完成再赋值
        ue.setContent($("#tempContent").val());  //赋值给UEditor
    });


    $("#fabiaoBtn").click(function () {


        $.ajax({
            url:ip_port + "user/updatetopic",
            type:"post",
            async: false,
            contentType: "application/json",
            dataType:"json",
            data:JSON.stringify({
                id:$("#id").val(),
                title: $("#title").val(),
                content:ue.getPlainTxt(),
                uid:$("#uid").val(),
                sid:$("#sid").val()
            }),
            success:function (msg) {
                if(msg.status=="success"){
                 //   alert("success")

                    window.location.href=ip_port +　"bbs/opentopic?id=" + msg.data.id;
                }else{
                    alert("error")
                    window.location.href=ip_port +　"bbs/towritetopic";
                }
            },error:function () {
                alert("error");
            }
        });
         return false;
    });
    get2ClassType();

    $("#sectionType").change(function () {
        get2ClassType();
    });


});